package com.androidx.p013lv.base.utils;

import com.androidx.p013lv.base.bean.DateBean;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/* renamed from: com.androidx.lv.base.utils.SpecialCalendar */
public class SpecialCalendar {
    static SpecialCalendar specialCalendar;

    public static SpecialCalendar getInstance() {
        if (specialCalendar == null) {
            specialCalendar = new SpecialCalendar();
        }
        return specialCalendar;
    }

    public boolean isLeapYear(int i) {
        int i2 = i % 100;
        if (i2 == 0 && i % 400 == 0) {
            return true;
        }
        if (i2 == 0 || i % 4 != 0) {
            return false;
        }
        return true;
    }

    public int getDaysOfMonth(int i, int i2) {
        boolean isLeapYear = isLeapYear(i);
        switch (i2) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                return 31;
            case 2:
                return isLeapYear ? 29 : 28;
            case 4:
            case 6:
            case 9:
            case 11:
                return 30;
            default:
                return 0;
        }
    }

    public List<DateBean> getCalendar(Calendar calendar) {
        Calendar instance = Calendar.getInstance();
        instance.set(1, calendar.get(1));
        instance.set(2, calendar.get(2));
        instance.set(5, calendar.get(5));
        int daysOfMonth = getDaysOfMonth(instance.get(1), instance.get(2) + 1);
        instance.set(5, 1);
        int i = instance.get(7) - 1;
        instance.add(2, -1);
        int daysOfMonth2 = getDaysOfMonth(instance.get(1), instance.get(2) + 1);
        ArrayList arrayList = new ArrayList();
        int i2 = 0;
        for (int i3 = 0; i3 < i; i3++) {
            arrayList.add(new DateBean(instance.get(1), instance.get(2) + 1, (daysOfMonth2 - i) + i3 + 1));
        }
        instance.add(2, 1);
        for (int i4 = 1; i4 <= daysOfMonth; i4++) {
            arrayList.add(new DateBean(instance.get(1), instance.get(2) + 1, i4));
        }
        instance.add(2, 1);
        int size = 7 - (arrayList.size() % 7);
        while (i2 < size) {
            i2++;
            arrayList.add(new DateBean(instance.get(1), instance.get(2) + 1, i2));
        }
        return arrayList;
    }
}
